home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
challenge
/
12.09-Sep96
/
Testcode96.09R1.sit.hqx
/
Testcode96.09R1
/
2 Fib app R1
/
FibApp.java
< prev
next >
Wrap
Text File
|
1996-08-18
|
415b
|
21 lines
public class FibApp
{
public static int Fib1(int n,int i,int j)
{
if (n==1) return i;
else if (n==2) return j;
else if (n==3) return i+j;
else return Fib1(n-1,j,i+j); /* really terrible application of recursion for a point */
}
public static int Fib()
{
return Fib1(40,1,1);
}
public static void main(String argv[])
{
System.out.println( "Correct result is "+Integer.toString(Fib() ) );
}
}